package com.study.springairag.etl.transformers;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.model.transformer.KeywordMetadataEnricher;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author dejavu
 * @since 2025/7/24
 *
 * 关键字增强
 * 此扩充器对于提高文档可搜索性和为文档生成标签或类别特别有用。
 */
@Component
public class MyKeywordEnricher  {
    private final ChatModel chatModel;

    MyKeywordEnricher (ChatModel chatModel) {
        this.chatModel = chatModel;
    }

    public List<Document> enrichDocuments(List<Document> documents) {
        KeywordMetadataEnricher enricher = new KeywordMetadataEnricher(this.chatModel, 5);
        return enricher.apply(documents);
    }

}
